package srzy.module

import java.io.FileWriter
import srzy.common.Logging
import srzy.dao.DBUtil
import spray.json._
import DefaultJsonProtocol._
object DBRec extends AbsCaseDeal with Logging {

  val dbSource = DBUtil("CaseInfoSource")

  def deal = {
    try {
      val caseName = getCaseInfo.caseName
      //      val realFullCdr = getCaseInfo.cdrInfo.realFull.mkString("\n")
      val realFullCdr = getCaseInfo.realFullCdrs.toJson.prettyPrint
      val realReceDCCMsg = getCaseInfo.realReceDCCMsg.mkString("\n-----\n")
      val realReceFromSMMsg = getCaseInfo.realReceFromSMMsg.mkString("\n")
      val realSendToSMMsg = getCaseInfo.realSendToSMMsg.mkString("\n")

      dbSource.updateCaseInfo(caseName,
        realFullCdr,
        getCaseInfo.realReceDCCMsg.mkString("\n-----\n"),
        getCaseInfo.realReceFromSMMsg.mkString("\n"),
        getCaseInfo.realSendToSMMsg.mkString("\n"))
    } catch {
      case ex: Exception => logger.error(ex.getMessage(), ex)
    }
  }

}